#!/usr/bin/perl -w

use strict;
use utf8;

my @arr = ();
my $tmax = -1;

while (<STDIN>)
{
	if (/unsat/)
	{
		print "UNSAT!\n";
		exit(1);
	}

	if (my ($t,$x,$y,$v) = m/\(= \(S (\d+) (\d+) (\d+)\) (true|false)\)/)
	{
		next unless $x > 0 and $x <= 5 and $y > 0 and $y <= 5;
		$tmax = $t if $t > $tmax;
		$arr[25*$t + 5*($y-1) + ($x-1)] = (($v eq 'true') ? '□' : '.');
	}
}

for (my $t = 0; $t <= $tmax; ++$t)
{
	print "Board at time $t:\n";
	for (my $y = 0; $y < 5; ++$y)
	{
		print "  ";
		for (my $x = 0; $x < 5; ++$x)
		{
			my $x = $arr[25*$t + 5*$y + $x] || '?';
			print $x . ' ';
		}
		print "\n";
	}
}
